[POWERPC][XEN] Add information into flat devtree needed to create a start_info_t...
authorHollis Blanchard <hollisb@us.ibm.com>
Tue, 6 Feb 2007 19:42:19 +0000 (13:42 -0600)
committerHollis Blanchard <hollisb@us.ibm.com>
Tue, 6 Feb 2007 19:42:19 +0000 (13:42 -0600)
Signed-off-by: Ryan Harper <ryanh@us.ibm.com>
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
--HG--
extra : transplant_source : %F2%18u%E3%DC%0B%E8%C4%E0%DE%996%97%3C%B3UX%F6%C4%BD

tools/libxc/powerpc64/mk_flatdevtree.c
tools/libxc/powerpc64/mk_flatdevtree.h
tools/libxc/powerpc64/xc_linux_build.c

index 670b236f37ad4e5e244c1fb8a9b64a4e795403a0..17085aeca1c878df1821a163a84a90458a985ca4 100644 (file)
@@ -316,13 +316,17 @@ int make_devtree(struct ft_cxt *root,
                  unsigned long shadow_mb,
                  unsigned long initrd_base,
                  unsigned long initrd_len,
-                 const char *bootargs)
+                 const char *bootargs,
+                 uint64_t shared_info_paddr,
+                 unsigned long console_evtchn,
+                 uint64_t console_paddr,
+                 unsigned long store_evtchn,
+                 uint64_t store_paddr)
 {
     struct boot_param_header *bph = NULL;
     uint64_t val[2];
     uint32_t val32[2];
     unsigned long remaining;
-    unsigned long rma_reserve = 4 * PAGE_SIZE;
     unsigned long initrd_end = initrd_base + initrd_len;
     int64_t shadow_mb_log;
     uint64_t pft_size;
@@ -351,10 +355,26 @@ int make_devtree(struct ft_cxt *root,
 
     /* you MUST set reservations BEFORE _starting_the_tree_ */
 
-    /* reserve some pages at the end of RMA */
-    val[0] = cpu_to_be64((u64) (rma_bytes - rma_reserve));
-    val[1] = cpu_to_be64((u64) rma_reserve);
-    ft_add_rsvmap(root, val[0], val[1]);
+    /* reserve shared_info_t page */
+    if (shared_info_paddr) {
+        val[0] = cpu_to_be64((u64) shared_info_paddr);
+        val[1] = cpu_to_be64((u64) PAGE_SIZE);
+        ft_add_rsvmap(root, val[0], val[1]);
+    }
+
+    /* reserve console page for domU */
+    if (console_paddr) {
+        val[0] = cpu_to_be64((u64) console_paddr);
+        val[1] = cpu_to_be64((u64) PAGE_SIZE);
+        ft_add_rsvmap(root, val[0], val[1]);
+    }
+
+    /* reserve xen store page for domU */
+    if (store_paddr) {
+        val[0] = cpu_to_be64((u64) store_paddr);
+        val[1] = cpu_to_be64((u64) PAGE_SIZE);
+        ft_add_rsvmap(root, val[0], val[1]);
+    }
 
     /* reserve space for initrd if needed */
     if ( initrd_len > 0 )  {
@@ -419,19 +439,19 @@ int make_devtree(struct ft_cxt *root,
     /* xen = root.addnode('xen') */
     ft_begin_node(root, "xen");
 
-    /* start-info is the first page in the RMA reserved area */
-    val[0] = cpu_to_be64((u64) (rma_bytes - rma_reserve));
-    val[1] = cpu_to_be64((u64) PAGE_SIZE);
-    ft_prop(root, "start-info", val, sizeof(val));
-
     /*  xen.addprop('version', 'Xen-3.0-unstable\0') */
-    ft_prop_str(root, "version", "Xen-3.0-unstable");
+    ft_prop_str(root, "compatible", "Xen-3.0-unstable");
 
     /* xen.addprop('reg', long(imghandler.vm.domid), long(0)) */
     val[0] = cpu_to_be64((u64) domid);
     val[1] = cpu_to_be64((u64) 0);
     ft_prop(root, "reg", val, sizeof(val));
 
+    /* point to shared_info_t page base addr */
+    val[0] = cpu_to_be64((u64) shared_info_paddr);
+    val[1] = cpu_to_be64((u64) PAGE_SIZE);
+    ft_prop(root, "shared-info", val, sizeof(val));
+
     /* xen.addprop('domain-name', imghandler.vm.getName() + '\0') */
     /* libxc doesn't know the domain name, that is purely a xend thing */
     /* ft_prop_str(root, "domain-name", domain_name); */
@@ -439,16 +459,41 @@ int make_devtree(struct ft_cxt *root,
     /* add xen/linux,phandle for chosen/interrupt-controller */
     ft_prop_int(root, "linux,phandle", xen_phandle);
 
-    /* xencons = xen.addnode('console') */
-    ft_begin_node(root, "console");
+    if (console_paddr != 0) {
+        /* xencons = xen.addnode('console') */
+        ft_begin_node(root, "console");
 
-    /* xencons.addprop('interrupts', 1, 0) */
-    val32[0] = cpu_to_be32((u32) 1);
-    val32[1] = cpu_to_be32((u32) 0);
-    ft_prop(root, "interrupts", val32, sizeof(val32));
+        /* console_paddr */
+        val[0] = cpu_to_be64((u64) console_paddr);
+        val[1] = cpu_to_be64((u64) PAGE_SIZE);
+        ft_prop(root, "reg", val, sizeof(val));
 
-    /* end of console */
-    ft_end_node(root);
+        /* xencons.addprop('interrupts', console_evtchn, 0) */
+        val32[0] = cpu_to_be32((u32) console_evtchn);
+        val32[1] = cpu_to_be32((u32) 0);
+        ft_prop(root, "interrupts", val32, sizeof(val32));
+
+        /* end of console */
+        ft_end_node(root);
+    }
+
+    if (store_paddr != 0) {
+        /* start store node */
+        ft_begin_node(root, "store");
+
+        /* store paddr */
+        val[0] = cpu_to_be64((u64) store_paddr);
+        val[1] = cpu_to_be64((u64) PAGE_SIZE);
+        ft_prop(root, "reg", val, sizeof(val));
+
+        /* store event channel */
+        val32[0] = cpu_to_be32((u32) store_evtchn);
+        val32[1] = cpu_to_be32((u32) 0);
+        ft_prop(root, "interrupts", val32, sizeof(val32));
+
+        /* end of store */
+        ft_end_node(root);
+    }
 
     /* end of xen node */
     ft_end_node(root);
index c5d39eb08834271bbdd5e2b3688f8d3ab3008719..63d425dd90db67fbb76db482c306fa26f3dfaa8f 100644 (file)
@@ -32,7 +32,12 @@ extern int make_devtree(struct ft_cxt *root,
                         unsigned long shadow_mb,
                         unsigned long initrd_base,
                         unsigned long initrd_len,
-                        const char *bootargs);
+                        const char *bootargs,
+                        uint64_t shared_info_paddr,
+                        unsigned long console_evtchn,
+                        uint64_t console_paddr,
+                        unsigned long store_evtchn,
+                        uint64_t store_paddr);
 
 #define MAX_PATH 200
 #define BUFSIZE 1024
index 27da7cf6c8f35ce6d17b50d82acace1f77703f0f..e6b45ec4667bda99c5fb744d060ca7cfc1e4e2c7 100644 (file)
@@ -33,6 +33,7 @@
 #include <xc_private.h>
 #include <xg_private.h>
 #include <xenctrl.h>
+#include <xen/arch-powerpc.h>
 
 #include "flatdevtree_env.h"
 #include "flatdevtree.h"
@@ -109,34 +110,6 @@ out:
     return rc;
 }
 
-static unsigned long create_start_info(
-        start_info_t *start_info,
-        unsigned int console_evtchn,
-        unsigned int store_evtchn,
-        unsigned long nr_pages,
-        unsigned long rma_pages)
-{
-    unsigned long start_info_addr;
-    uint64_t rma_top;
-
-    memset(start_info, 0, sizeof(*start_info));
-    snprintf(start_info->magic, sizeof(start_info->magic),
-             "xen-%d.%d-powerpc64HV", 3, 0);
-
-    rma_top = rma_pages << PAGE_SHIFT;
-    DPRINTF("RMA top = 0x%"PRIX64"\n", rma_top);
-
-    start_info->nr_pages = nr_pages;
-    start_info->shared_info = rma_top - PAGE_SIZE;
-    start_info->store_mfn = (rma_top >> PAGE_SHIFT) - 2;
-    start_info->store_evtchn = store_evtchn;
-    start_info->console.domU.mfn = (rma_top >> PAGE_SHIFT) - 3;
-    start_info->console.domU.evtchn = console_evtchn;
-    start_info_addr = rma_top - 4*PAGE_SIZE;
-
-    return start_info_addr;
-}
-
 static void free_page_array(xen_pfn_t *page_array)
 {
     free(page_array);
@@ -191,7 +164,6 @@ int xc_linux_build(int xc_handle,
                    unsigned int console_evtchn,
                    unsigned long *console_mfn)
 {
-    start_info_t start_info;
     struct domain_setup_info dsi;
     xen_pfn_t *page_array = NULL;
     unsigned long nr_pages;
@@ -199,9 +171,11 @@ int xc_linux_build(int xc_handle,
     unsigned long kern_addr;
     unsigned long initrd_base = 0;
     unsigned long initrd_len = 0;
-    unsigned long start_info_addr;
     unsigned long rma_pages;
     unsigned long shadow_mb;
+    u64 shared_info_paddr;
+    u64 store_paddr;
+    u64 console_paddr;
     u32 remaining_kb;
     u32 extent_order;
     u64 nr_extents;
@@ -281,25 +255,28 @@ int xc_linux_build(int xc_handle,
         goto out;
     }
 
+    /* determine shared_info, console, and store paddr */
+    shared_info_paddr = (rma_pages << PAGE_SHIFT) -
+                        (RMA_SHARED_INFO * PAGE_SIZE);
+    console_paddr = (rma_pages << PAGE_SHIFT) - (RMA_CONSOLE * PAGE_SIZE);
+    store_paddr = (rma_pages << PAGE_SHIFT) - (RMA_STORE * PAGE_SIZE);
+
+    /* map paddrs to mfns */
+    *store_mfn = page_array[(xen_pfn_t)(store_paddr >> PAGE_SHIFT)];
+    *console_mfn = page_array[(xen_pfn_t)(console_paddr >> PAGE_SHIFT)];
+    DPRINTF("console_mfn->%08lx store_mfn->%08lx\n", *console_mfn,
+            *store_mfn);
+
     /* build the devtree here */
     DPRINTF("constructing devtree\n");
-    if (make_devtree(&devtree, domid, mem_mb, (rma_pages*PAGE_SIZE), shadow_mb,
-                     initrd_base, initrd_len, cmdline) < 0) {
+    if (make_devtree(&devtree, domid, mem_mb, (rma_pages << PAGE_SHIFT),
+                     shadow_mb, initrd_base, initrd_len, cmdline, 
+                     shared_info_paddr, console_evtchn, console_paddr,
+                     store_evtchn, store_paddr) < 0) {
         DPRINTF("failed to create flattened device tree\n");
         rc = -1;
         goto out;
     }
-    
-    /* start_info stuff: about to be removed  */
-    start_info_addr = create_start_info(&start_info, console_evtchn,
-                                        store_evtchn, nr_pages, rma_pages);
-    *console_mfn = page_array[start_info.console.domU.mfn];
-    *store_mfn = page_array[start_info.store_mfn];
-    if (install_image(xc_handle, domid, page_array, &start_info,
-                      start_info_addr, sizeof(start_info_t))) {
-        rc = -1;
-        goto out;
-    }
 
     devtree_addr = DEVTREE_ADDR;
     DPRINTF("loading flattened device tree to 0x%lx[0x%x]\n",